package com.class05.i_polymorphic;

public class TestMain {
    public static void main(String[] args) {
        double d = 1000; //向上转换(小转大，自动，大装小)
        Animal animal = new Cat();
        animal.eat();//dog重写的方法

        int f = (int) d;//向下转换(大转小，强转，小装大)
//        怎么判断类型: instanceof
//  判断结果是boolean型
        if (animal instanceof Dog) {
            Dog dog = (Dog) animal;
            dog.lookHome();
            dog.eat();
        }
        if (animal instanceof Cat) {
            Cat cat = (Cat) animal;
            cat.catchMouse();
            cat.eat();
        }


    }
}
